package my.org.swing;

import my.org.swing.date.DateField;
import my.org.swing.date.DateTheme;
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Demo {

    public static void main(String[] args) {
        JPanel p = new JPanel(new BorderLayout());
        DateField dateField = new DateField();

        JButton btn = new JButton("update theme");
        btn.addActionListener(e -> {
            if (DateTheme.isDarkTheme()) {
                DateTheme.changeLightTheme();
            } else {
                DateTheme.changeDarkTheme();
            }

            dateField.clearOldWindow();
            btn.setText("Theme = " + (DateTheme.isDarkTheme() ? "dark" : "light"));
        });

        p.add(dateField, BorderLayout.EAST);
        p.add(btn);

        JFrame frame = new JFrame("date chooser Demo");
        frame.setSize(300, 70);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(p);
        frame.setVisible(true);
    }
}
